<?php

namespace app\api\controller;

use app\api\service\CartService;
use app\api\service\IndexService;
use app\api\service\OrderService;
use app\ApiController;
use support\Request;

class IndexController extends ApiController
{
    /**
     * 小程序首页
     */
    public function index()
    {
        $indexService = new IndexService();
        $data = $indexService->getIndexData();
        return sparkSuccess($data);
    }

    /**
     * 搜索
     */
    public function search()
    {
        $indexService = new IndexService();
        $data = $indexService->search(request()->post());
        return sparkSuccess($data);
    }


    /**
     * 获取营销插件的配置
     */
    public function marketingConfig()
    {
        $orderService = new OrderService();
        return sparkSuccess($orderService->getMarketingConfig());
    }

    /**
     * 获取购物车数量
     */
    public function cartNum()
    {
        $cartService = new CartService();
        $cartInfo = $cartService->getCartNum(\Tinywan\Jwt\JwtToken::getCurrentId());
        return sparkSuccess($cartInfo);
    }



}
